<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<%@include file="common.jsp" %>
</head>
<body>
<input type="hidden" name="id" value="${userInfo.id }">
		<br/>
		<br/>
		${userInfo.nickName }
		<br/>
		<br/>
		<fmt:formatDate pattern="yyyy-MM-dd" value="${userInfo.birthDay}" />
		<br/>
		<br/>
		${userInfo.gender}
		<br/>
		<br/>
		${userInfo.cityName }
		<br/>
		<br/>
		${userInfo.introduce }
		<br/>
		<br/>
		${userInfo.hope }
		<br/>
		<br/>
		<div id="hobbyDiv">
			
		</div>
		<br/>
		<br/>
	</form>
	<hr/>
	<br/>
	<br/>
	<c:forEach items="${userInfo.photos }" var="item">
		${item.name }<br/>
	</c:forEach>
	<hr/>
	<br/>
	<br/>
	<c:forEach items="${userInfo.moods }" var="item">
		${item.mood }<br/>
	</c:forEach>
</form>
<hr/>
<br/>
<div id="contact" >
	<a id="contactHref">查看联系方式</a>
</div>

<script type="text/javascript">
$(document).ready(function(){
    $.ajax({
        type: 'POST',
        url: '<%=contexPath%>/hobby/0',
        data: {},
        success: function (data) {
         		$.each(data,function(index,item){
         			if(in_array(item.id,"${userInfo.hobbys}")){
         				$("#hobbyDiv").append(item.desc+"<br/>");
         			}
         			
         		});
        },
        dataType: 'json'
    });
    
    function in_array(search,array){
        for(var i in array){
            if(array[i]==search){
                return true;
            }
        }
        return false;
    }
    
    $("#contactHref").on("click",function(){
    	$.ajax({
            type: 'POST',
<%--             url: '<%=contexPath%>/user/contact/'+${userInfo.id }, --%>
			url: '<%=contexPath%>/user/contact/65348133',
            data: {},
            success: function (data) {
            	if(data.id == null){
            		$("#contact").empty();
                	$("#contact").append("无权限");
                	$("#contact").append("<br/><a href='<%=contexPath%>/user/recharge.html'>充值为会员</a>");
            	} else {
            		$("#contact").empty();
                	$("#contact").append("电话："+data.tel);
                	$("#contact").append("<br/>邮箱："+data.email);
                	$("#contact").append("<br/>QQ："+data.qq);
                	$("#contact").append("<br/>微信："+data.wx);
            	}
            },
            dataType: 'json'
        });
    });
});
</script>
</body>
</html>